<template>
  <div class="returnComment" v-if="returnFlog === index && returnFlog2 === index2">
    <div v-if="userInfoData._id || userName" class="has-loging">
      <div class="user-cover">
        <img :src="userInfoData.coverUrl | squareUrls" alt />
      </div>
      <div class="textarea">
        <el-input
          v-model="skillCommentData"
          type="textarea"
          :placeholder="userInfoData.name ? userInfoData.name + '：你想对评论说些什么？' : userName + '你想对这篇文章说些什么？'"
        ></el-input>
      </div>
      <div class="btn" v-if="skillCommentData">
        <el-button type="small" @click="sendReturnCommentData({data,index})">发送</el-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "return-comment",
  props: {
    userInfoData: {},
    userName: {
      type: String,
      default() {
        return "";
      }
    },
    returnFlog: {
      type: Number,
      default() {
        return 0;
      }
    },
    returnFlog2: {
      type: Number,
      default() {
        return 0;
      }
    },
    data: {
      type: Object,
      default() {
        return {};
      }
    },
    index: {
      type: Number,
      default() {
        return 0;
      }
    },
    index2: {
      type: Number,
      default() {
        return 0;
      }
    }
  },
  data() {
    return {
      skillCommentData: ""
    };
  },
  methods: {
    sendReturnCommentData({ data, index }) {
      this.$emit("_sendReturnCommentData", {
        data,
        skillCommentData: this.skillCommentData,
        index
      });
    }
  }
};
</script>

<style lang="sass" scoped>
@import '@/assets/default.sass'
.returnComment
  width: 100%
  margin-top: 10px
  .has-loging
    width: 95%
    background-color: #eee
    margin-left: 5%
    padding: 10px 20px
    border-radius: 10px
    @include flex(space-between,center)
    .user-cover
      flex: 0 0 32px
      height: 32px
      overflow: hidden
      border-radius: 5px
      @include flex(center,center)
      >img
        width: 100%
        height: auto
    .textarea
      flex: 1
      margin: 0 10px
    .btn
      flex: 0 0 60px
      text-align: right
</style>